let { z } = require('zod')

const categorySchema = z.lazy(() =>
  z.object({
    name: z.string(),
    // 可选 children 属性的值是一个数组 里面的每个元素是 categorySchema 递归
    children: z.array(categorySchema).optional(),
  })
);

const data = {
  name: "大前端",
  children: [
    {
      name: "Node.js",
      children: [{ name: "Vue.js" }],
    },
  ],
};

const result1 = categorySchema.parse(data)
// result1  { name: '大前端', children: [ { name: 'Node.js', children: [Array] } ] }
console.log('result1 ', result1)
